-- make_sunshine
-- create by cheny3
-- 制造太阳光

local function findGarden()
    -- 找一下当前有没有花园
    local pos;
    for i = 1, GRID_SIZE do
        local grid = DungeonM.getGridByPos(i);
        if grid.type == GRID_TYPE_GARDEN
            and grid.state ~= GRID_STATE_DISABLE
            and grid:isOpened() then
            -- 已经打开未失效
            pos = i;
            break;
        end
    end
    return pos;
end

return {
    -- 判断
    canTrigger = function(args)
        local pos = findGarden();
        if not pos then
            return false;
        end

        return BineM.canMakeSunshine(pos);
    end,

    -- 触发
    trigger = function(args)
        local pos = findGarden();
        if not pos then
            return false;
        end

        -- 制造太阳光
        if DungeonActionM.go("make_sunshine", pos) then
            return true;
        end
        return false;
    end,
};
